package com.woniuxy.reservation.app.apiImpl;

import cn.hutool.core.bean.BeanUtil;
import com.woniuxy.cloud.mall95.log.Log;
import com.woniuxy.reservation.client.param.InsertReservationParam;
import com.woniuxy.reservation.client.param.UpdateReservationStateParam;
import com.woniuxy.reservation.client.reservationclient.ReservationManageClient;
import com.woniuxy.reservation.service.ReservationService;
import com.woniuxy.reservation.service.serviceparam.InsertReservationServiceParam;
import com.woniuxy.reservation.service.serviceparam.UpdateReservationStateServiceParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import result.Result;

@RestController
public class ReservationManageClientApiImpl implements ReservationManageClient {
    @Autowired
    private ReservationService reservationService;
    @Override
    @Log("添加预约")
    public Result insertReservation(InsertReservationParam param) {
        InsertReservationServiceParam insertReservationServiceParam = BeanUtil.toBean(param, InsertReservationServiceParam.class);
        reservationService.insertReservation(insertReservationServiceParam);
        return Result.success();
    }

    @Override
    @Log("根据ID修改预约状态")
    public Result updateReservationState(UpdateReservationStateParam param) {
        UpdateReservationStateServiceParam updateReservationStateServiceParam = BeanUtil.toBean(param, UpdateReservationStateServiceParam.class);
        reservationService.updateReservationState(updateReservationStateServiceParam);
        return Result.success();
    }

    @Override
    @Log("根据ID取消预约")
    public Result deleteReservation(Integer storeId, Integer reservationId) {
        reservationService.deleteReservation(storeId,reservationId);
        return Result.success();
    }
}
